package br.com.caelum.vraptor.controller;


import javax.inject.Inject;

import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.components.AdmSessioned;
import br.com.caelum.vraptor.dao.AdministradorDAO;
import br.com.caelum.vraptor.entidades.Administrador;
public class LoginadmController {
	
	 @Inject
     private Result result;
     @Inject
     private AdministradorDAO administradorDAO;
     @Inject
     private AdmSessioned admSessioned;
    
     public LoginadmController() {
             
     }
    
     public void login(String matricula, String senha){
     	Administrador adm = administradorDAO.find(matricula, senha);
         admSessioned.login(adm);
         if(admSessioned.isLogado()){
             result.redirectTo(IndexController.class).home();;
             }else{
            	 result.redirectTo(IndexController.class).error();
            	 }
     }
            
     public void logar(){
     	
     }
    
     public void logout(){
             admSessioned.logout();
             result.redirectTo(this).logar();
     }

}




